﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using mebc.reflection;

namespace mebc
{
    public interface IMessage
    {
        Type MessageType { get;  }
        object Value { get;  }
    }

    public class Message<T> : IMessage
    {
        public Message() {}
        public Message(T value) { Value = value; }

        public Type MessageType { get { return typeof (T); } }

        private T _value;
        public object Value
        {
            get { return _value; }
            set { _value = (T)value;  }
        }
    }


    public interface IFunctionalUnit
    {
        void InputPipe(IMessage message);
        void SendMessage(IMessage message);
        event Action<IMessage> OutputPipe;
        MetaData GetMetaData();
    }

    public abstract class FunctionalUnit : IFunctionalUnit
    {
        public abstract void InputPipe(IMessage message);


        public void SendMessage(IMessage message)
        {
            OutputPipe(message);
        }

        public event Action<IMessage> OutputPipe;


        public abstract MetaData GetMetaData();
    }
}
